 /*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package utils;

//import java.sql.Connection;
//import java.sql.DriverManager;
//import java.sql.SQLException;
//import java.util.MissingResourceException;
//import java.util.ResourceBundle;
//import javax.swing.JOptionPane;
//
//
//public class Conexao
//{	private static Conexao conexao = null;
//	private Connection conn;
//
//	private Conexao()
//	{	try
//		{
//                        ResourceBundle prop = ResourceBundle.getBundle("utils.bd");
//
//                        String driver = prop.getString("driver");
//                        String bd = prop.getString("bd");
//			String usuario = prop.getString("usuario");
//                        String senha = prop.getString("senha");
//
//                        //Verifica se o driver do postgre está instalado
//			Class.forName(driver);
//			conn = DriverManager.getConnection(bd,usuario,senha);
//		}
//		catch (SQLException e)
//		{
//                        JOptionPane.showMessageDialog(null, e);
//
//		}
//		catch (ClassNotFoundException e)
//		{	JOptionPane.showMessageDialog(null, e);
//		}
//                catch(MissingResourceException e)
//		{	JOptionPane.showMessageDialog(null, e);
//		}
//	}
//
//	public static Connection getConnection()
//	{	if (conexao == null)
//		{	conexao = new Conexao();
//		}
//		return conexao.conn;
//	}
//
//	public void close()
//	{	try
//		{	conn.close();
//		}
//		catch(SQLException e)
//		{ }
//	}
//}
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

/**
 *
 * @author Usuario
 */
public class Conexao {

    static Connection conexao;

    public static Connection getConnection() {
        if (conexao == null) {
            try {
                Class.forName("com.mysql.jdbc.Driver");
                conexao = DriverManager.getConnection(
                        "jdbc:mysql://localhost/scev","root", "");
            } catch (ClassNotFoundException cnfe) {
                JOptionPane.showMessageDialog(null, cnfe);
            } catch (SQLException sqlex) {
                JOptionPane.showMessageDialog(null, sqlex);
            }
        }
        return conexao;
    }

    //teste Heredia
    
    
    public ResultSet executeQuery(String sql)  {
{
        Connection db = Conexao.getConnection();
        Statement st;
        try {
            st = (Statement) db.createStatement();
            ResultSet rs = st.executeQuery(sql);
            return rs;
        } catch (SQLException ex) {
            Logger.getLogger(Conexao.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }

}}
